<template>
	<view class="mainbgc" v-show="show">
		<view class="mainpadding2">
			<view class="flexbetween flex_wrap">
				<view class="itembox margin-top flexcenter" v-if="list.data.length" v-for="item in list.data" :key="item.id">
					<view class="item ffffff" @click="jumpdetail(item.id)">
						<view class="topimg">
							<image :src="item.image_text" mode=""></image>
						</view>
						<view class="paddingzdy">
							<view class="nostrongtext yhxiankuan">{{item.title}}</view>
							<view class="margin-top pricetext">￥{{item.goodsprice.price}}</view>
						</view>
					</view>
					
				</view>
				
			</view>
				<view class="flexcenter1" v-if="!list.data.length">
					<view class="placeholderimg" style="margin-top: 300rpx;">
						<image src="../../static/images/bg-icons/placeholderimg.png" mode=""></image>
					</view>
					<view class="zanwushuju">暂无数据~</view>
				</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				
				show:false,
				
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			jumpdetail(id) {
				uni.navigateTo({
					url: '/pages/shopping/productdetail?id=' + id
				})
			},
			// 热门推荐列表
			init(isPage, page) {
				let _this = this;
				httpRequest.request('api/goods/tPirceGoods', 'GET', {
					page: page || 1,
					limit: _this.limit,
				}, false, false, false).then(res => {
					this.show=true
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					this.show=true
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.mainpadding2{
		padding: 0 30rpx 30rpx;
	}
	.itembox{
		width: 48%;
		
	}
	.item{
		padding: 0;
		margin:0;
		border-radius: 10rpx;
	}
	.topimg{
		width: 328rpx;
		height: 328rpx;
		border-radius: 10rpx;
		image{
			width: 100%;
			height: 100%;
			border-radius: 10rpx;
		}
	}
	.pricetext{
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FF5C00;
	}
	.paddingzdy{
		padding: 30rpx 30rpx 30rpx 10rpx;
	}
</style>
